The world is not yet flat: Transport costs matter!

(c) Kristian Behrens, W. Mark Brown, and Théophile Bougna

—

Important information on compiling and running the C codes.


The GNU Scientific Libraries have to be linked (in particular libgsl.a). They are available at https://www.gnu.org/software/gsl/. We used version 1.16 of the libraries.

All header search paths and library search paths have to be fully specified in the build options. The code was developed on a MacPro/MacBookPro running OS 10.12 and 10.13. The SDK version is macOS 10.12). The code was also tested on older SDKs. Please make sure that you use the correct SDK, segmentation faults may result from improper specifications of the SDK.

For the implementation at Statistics Canada, the code was compiled on a Microsoft server using Visual C++.


The command line structure for running the executable is as follows:

./[EXEC_NAME] ./input_file.txt ./io_table.txt ./[OUTPUT_FILE] 311111 num num5 0

—

EXEC_NAME		= name of the executable you produced

input_file.txt		= file that contains the plants to be processed

io_table.txt		= file that contains the input-output table elements

OUTPUT_FILE		= name of the output file to be created

311111			= don’t change this, it’s not used here

num			= use the ‘num’ nearest plants in each industry for the computations

0			= don’t change this, it’s not used here

—

Here is a sample test and output (using only 5000 plants for illustrative purposes):

C33175:iolinks behrens_k$ ./iolinks2 ./small_sample_plants.txt ./IO_matrix.txt ./output.txt 311111 5 0

./iolinks2: Processing the file with the firms...
./iolinks2: Number of firms to be processed = 5000
./iolinks2: Industry to be processed (counterfactual only) = 311111
./iolinks2: Smoothing across 5 nearest firms
./iolinks2: Computing actual IO-links for all firms
./iolinks2: Starting to compute the IO-linkages...
Iteration 0 done
Iteration 100 done
Iteration 200 done
Iteration 300 done
Iteration 400 done
Iteration 500 done
Iteration 600 done
Iteration 700 done
Iteration 800 done
Iteration 900 done
Iteration 1000 done
Iteration 1100 done
Iteration 1200 done
Iteration 1300 done
Iteration 1400 done
Iteration 1500 done
Iteration 1600 done
Iteration 1700 done
Iteration 1800 done
Iteration 1900 done
Iteration 2000 done
Iteration 2100 done
Iteration 2200 done
Iteration 2300 done
Iteration 2400 done
Iteration 2500 done
Iteration 2600 done
Iteration 2700 done
Iteration 2800 done
Iteration 2900 done
Iteration 3000 done
Iteration 3100 done
Iteration 3200 done
Iteration 3300 done
Iteration 3400 done
Iteration 3500 done
Iteration 3600 done
Iteration 3700 done
Iteration 3800 done
Iteration 3900 done
Iteration 4000 done
Iteration 4100 done
Iteration 4200 done
Iteration 4300 done
Iteration 4400 done
Iteration 4500 done
Iteration 4600 done
Iteration 4700 done
Iteration 4800 done
Iteration 4900 done
./iolinks2: Elapsed time = 43d seconds


—

File structures:

The files with the plants have the following structure:

First line: Number of observations (plants)
Other lines: plant_id latitude longitude industry_code weight

(NOTE: industry_code and weight need to be specified but are not used)

The file with the industry mapping has the following structure:

Each line: industry_code internal_code

(NOTE: internal_code indexes array numbers, so this runs from 0-number_of_industries; in our case, 258 industries - NAICS 6-digit)

The files with the input-output weights have the following structure.

Each line: [io_ij] = amount industry i buys from industry j

(NOTE: This is a matrix with 258 x 258 elements in our case)


Sample files are provided with the code for illustrative purposes. We also provide a MacOS X 10.13 precompiled executable (mindist_exec). Please run this as a command-line tool in the terminal.

—

Output structure:

Each column contains information for one plant. The first number is the plant_id, the last two columns are the input_distance and the output_distance. (NOTE: Columns 2 and 3 are the industry code and the corresponding number from the industry_mapping.txt file; we can disregard those).